﻿using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sparklings.RayTracing
{
    public enum RayColor
    {
        None = 0x00,
        Red = 0x04,
        Green = 0x02,
        Blue = 0x01,
        Yellow = 0x06,
        Purple = 0x05,
        Cyan = 0x03,
        White = 0x07,
        Black = 0x1000
    }
    public static class RayColorExtensionMethods
    {
        public static Color ToColor(this RayColor value)
        {
            switch (value)
            {
                case RayColor.None:
                    return new Color(60, 60, 60, 255);
                case RayColor.Black:
                    return new Color(40, 40, 40, 255);
                case RayColor.Red:
                    return new Color(255, 40, 40, 255);
                case RayColor.Green:
                    return new Color(80, 255, 90, 255);
                case RayColor.Blue:
                    return new Color(40, 40, 255, 255);
                case RayColor.Yellow:
                    return Color.Yellow;
                case RayColor.Purple:
                    return new Color(255, 40, 255, 255);
                case RayColor.Cyan:
                    return new Color(40, 255, 255, 255);
            }
            return Color.White;
        }
        public static bool Contains(this RayColor me, RayColor other)
        {
            if (me == RayColor.Black || other == RayColor.Black)
            {
                return false;
            }
            if ((((int)me) & ((int)other)) == (int)other)
            {
                return true;
            }
            return false;
        }
        public static RayColor Combined(this RayColor me, RayColor other)
        {
            if (other == RayColor.Black || me == RayColor.Black) return RayColor.Black;

            return (RayColor)(((int)me) | ((int)other));
        }
        public static RayColor Filtered(this RayColor me, RayColor other)
        {
            if (me == RayColor.Black) return RayColor.Black;

            return (RayColor)(((int)me) & (~((int)other)));
        }
    }
}
